const db = wx.cloud.database();
const app = getApp();
Page({
    data: {
        inputValue:null,
        numberPeople: 0,         //用餐人数
        currentNumber:0         //已选用餐人数
    },
    onLoad(options) {
        //读取桌数
        db.collection("store").doc("6d85a2b9629311a7076342b322de9447").get()
            .then(res => this.setData({
                numberPeople: res.data.deskNumber
            }));
    },
    selectNumber(event){
        let number = event.currentTarget.dataset.desk;
        this.setData({currentNumber:number});
    },
    focus(){
        this.setData({currentNumber:0});
    },
    input(event){
        this.setData({currentNumber:event.detail.value});
    },
    intoIndex(){
        if(this.data.currentNumber==0 && this.data.inputValue==null){
            wx.showModal({
                title: '提示',
                content: '请选用餐人数！',
              })
            return;
        }else{
            if(this.data.currentNumber!=0){
                app.globalData.numberPeople=this.data.currentNumber;
            }else{
                app.globalData.numberPeople=this.data.inputValue;
            }
            wx.navigateTo({
                url: '../index/index',
              })
        }
    }
})